package com.netease.nie.base.http;

/**
*
* HTTP Cookie
* @author KingsHunter
* @createDate August 16,2016
*
*/
public class Cookie {

    private com.ning.http.client.cookie.Cookie cookie;
    private boolean secure;
    
    public com.ning.http.client.cookie.Cookie getClientCookie() {
    	return cookie;
    }
    
    public Cookie(com.ning.http.client.cookie.Cookie cookie) {
    	this.cookie = cookie;
    }
    
    public Cookie(String domain, String name, String value, String path, int maxAge, boolean secure) {
    	cookie = new com.ning.http.client.cookie.Cookie(name, value, false, domain, path, maxAge, secure, false);
    	this.secure = secure;
    }
    
    @Override
    public String toString() {
    	if (cookie == null) {
    		return "Cookie: null";
    	}
        return String.format("Cookie: domain=%s, name=%s, value=%s, path=%s, maxAge=%d, secure=%s",
        		cookie.getDomain(),
        		cookie.getName(),
        		cookie.getValue(),
        		cookie.getPath(),
        		cookie.getMaxAge(),
        		secure);
    }
}
